﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DiskGalleryDataAPI.DataAccesss;

namespace DiskGallery
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DiskDataAccessor dbSelectAll = new DiskDataAccessor();
            GridView1.DataSource = dbSelectAll.SelectAll();
            GridView1.DataBind();

            if (Session["user"] != null)
            {
                if (Session["user"].ToString() == "admin")
                {
                    lnkNew.Visible = true;
                    btLogout.Visible = true;
                    btLogin.Visible = false;
                }
            }
            else
            {
                btLogout.Visible = false;
                btLogin.Visible = true;
                lnkNew.Visible = false;
            }
        }
        protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
        {
            /*            FileUpload IconUpload = (FileUpload)DetailsView1.FindControl("IconUpload");
                       IconUpload.FileContent

                        FileStream DiskIcon = File.Create(Server.MapPath("/Icons") + Guid.NewGuid() + ".jpg");*/
        }

        protected void btLogout_Click(object sender, EventArgs e)
        {
            Session["user"] = null;
            Response.Redirect("Login.aspx");
        }

        protected void btLogin_Click(object sender, EventArgs e)
        {
            Response.Redirect("Login.aspx");
        }

    }

}
